<?php
/**
 * Created by PhpStorm.
 * User: jwb
 * Date: 2020/5/12
 * Time: 16:37
 */

namespace App\Repositories;


use App\Models\AdminUser;
use App\Repositories\Eloquent\Repository;
use Encore\Admin\Facades\Admin;
use Encore\Admin\Grid;

class AdminUserRepository extends Repository
{
    function model()
    {
        return AdminUser::class;
    }

    //管理员账户
    public function adminGrid($orderColumn = 'id', $order = 'desc')
    {
        $grid = $this->grid();
        $grid->model()->where('id', '>', 1)->whereIn('role_type', [0, 1, 2])->orderBy($orderColumn, $order);
        return $grid;
    }

    public function deptGrid($orderColumn = 'id', $order = 'desc'): Grid
    {
        $user = Admin::user();
        $grid = $this->adminGrid($orderColumn, $order);
        $grid->model()->where('department_id', $user['department_id'])->where('role_type', 0);
        return $grid;
    }
}
